package com.itheima.Day11.ZuoYe.ZuoYe1;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.io.FileWriter;

public class Test {
    public static void main(String[] args) {

            File dir = new File("D:\\a");
            File dir1 = new File("D:\\b");
            File[] files = dir.listFiles();
            if(files !=  null){
                for(File f : files){
                    if(f.isFile()){
                        if(f.getName().endsWith(".java")){
                            FileUtil.copy(f,dir1,true);
                        }
                    }
                }
                File[] files1 = dir1.listFiles();
                for(File f : files1){
                    if(files1 !=  null){
                        if(f.getName().endsWith(".java")&&f.isFile()){
                            String replace = f.getName().replace(".java", ".txt");
                            FileUtil.rename(f,replace, true);
                        }
                    }

                        }
                    }
                }
            }
